<template>
    <div>
        <!-- 表格 -->
        <el-table :data="logs.list" border style="width: 100%" size="small">
            <el-table-column fixed type="index" label="序号" width="80"></el-table-column>
            <el-table-column fixed prop="realname" label="操作人"></el-table-column>
            <el-table-column fixed prop="content" label="内容"></el-table-column>
            <!-- <el-table-column label="操作" align="center" width="120" fixed="right">
                <template slot-scope="scope">
                    <el-link @click="deleteHandler(scope.row.id)" :underline="false">删除</el-link>
                    <el-link class="borrow" @click="editHandler(scope.row)" :underline="false">修改</el-link>
                </template>
            </el-table-column> -->
        </el-table>

        <!-- 分页 -->
        <el-pagination
            layout="total, prev, pager, next"
            @current-change="pageHandler"
            :page-size="logs.pageSize"
            :current-page="logs.page"
            :total="logs.total">
        </el-pagination>

        <!-- 新增 -->
        <!-- <el-dialog :title="title" :visible.sync="dialogVisible" width="60%">
            {{form}}
            <el-form ref="form" :model="form" label-width="80px">
                <el-form-item label="名称">
                    <el-input v-model="form.name"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="savelogHandler">确 定</el-button>
            </span>
        </el-dialog> -->
    </div>
</template>

<script>
import request from '@/utils/request'
import qs from 'qs'
export default {
    data() {
        return {
            logs: [],
            params: {
                page: 1,
                pageSize: 10
            },
            dialogVisible: false,
            form: {},
            title: ''
        }
    },
    created() {
        this.logFindAll()
    },
    methods: {
        // 新增
        addlogHandler() {
            this.dialogVisible = true;
            this.title = "新增物品类型信息"
        },
        // 确认
        savelogHandler() {
            request.post("/assetlog/saveOrUpdate",qs.stringify(this.form)).then(res => {
                console.log(res)
                this.dialogVisible = false;
                this.logFindAll()
                this.$notify({
                    title: '成功',
                    message: res.message,
                    type: 'success'
                });
            })
        },

        // 修改
        editHandler(row) {
            this.dialogVisible = true
            this.form = row;
            this.title = "修改物品类型信息"
        },

        // 查询所有类型
        logFindAll() {
            request.get("/baseLog/pageQuery",{params: this.params}).then(res => {
                this.logs = res.data
            })
        },
        // 分页
        pageHandler(page) {
            this.params.page = page
            this.logFindAll(this.params)
        }
    }
}
</script>
<style scoped>
    .btn {
        margin-bottom: .5rem;
    }
    .el-icon-delete {
        margin-right: .5rem;
    }
</style>